home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-3.98 / include / bfd.h < prev    next >
Encoding:
C/C++ Source or Header  |  1991-08-01  |  49.8 KB  |  1,555 lines

  1. /* A -*- C -*- header file for the bfd library
  2.    Copyright 1990, 1991 Free Software Foundation, Inc.
  3.    Contributed by Cygnus Support.
  4.  
  5. This file is part of BFD, the Binary File Diddler.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or
  10. (at your option) any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. /* bfd.h -- The only header file required by users of the bfd library 
  22.  
  23. This file is generated from various .c files, if you change it, your
  24. bits may be lost.
  25.  
  26. All the prototypes and definitions following the comment "THE FOLLOWING
  27. IS EXTRACTED FROM THE SOURCE" are extracted from the source files for
  28. BFD.  If you change it, someone oneday will extract it from the source
  29. again, and your changes will be lost.  To save yourself from this bind,
  30. change the definitions in the source in the bfd directory.  Type "make
  31. docs" and then "make headers" in that directory, and magically this file
  32. will change to reflect your changes.
  33.  
  34. If you don't have the tools to perform the extraction, then you are
  35. safe from someone on your system trampling over your header files.
  36. You should still maintain the equivalence between the source and this
  37. file though; every change you make to the .c file should be reflected
  38. here.  */
  39.  
  40. #ifndef __BFD_H_SEEN__
  41. #define __BFD_H_SEEN__
  42.  
  43. #include "ansidecl.h"
  44. #include "obstack.h"
  45.  
  46. /* Make it easier to declare prototypes (puts conditional here) */
  47. #ifndef PROTO
  48. #    if __STDC__
  49. #        define PROTO(type, name, arglist) type name arglist
  50. #    else
  51. #        define PROTO(type, name, arglist) type name ()
  52. #    endif
  53. #endif
  54.  
  55. #define BFD_VERSION "1.15"
  56.  
  57. /* forward declaration */
  58. typedef struct _bfd bfd;
  59.  
  60. /* General rules: functions which are boolean return true on success
  61.    and false on failure (unless they're a predicate).   -- bfd.doc */
  62. /* I'm sure this is going to break something and someone is going to
  63.    force me to change it. */
  64. typedef enum boolean {false, true} boolean;
  65.  
  66. /* Try to avoid breaking stuff */
  67. typedef  long int file_ptr;
  68.  
  69. /* Support for different sizes of target format ints and addresses */
  70.  
  71. #ifdef    HOST_64_BIT
  72. typedef HOST_64_BIT rawdata_offset;
  73. typedef HOST_64_BIT bfd_vma;
  74. typedef HOST_64_BIT bfd_word;
  75. typedef HOST_64_BIT bfd_offset;
  76. typedef HOST_64_BIT bfd_size_type;
  77. typedef HOST_64_BIT symvalue;
  78. typedef HOST_64_BIT bfd_64_type;
  79. #define fprintf_vma(s,x) \
  80.         fprintf(s,"%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
  81. #define printf_vma(x) \
  82.         printf(   "%08x%08x", uint64_typeHIGH(x), uint64_typeLOW(x))
  83. #else
  84. typedef struct {int a,b;} bfd_64_type;
  85. typedef unsigned long rawdata_offset;
  86. typedef unsigned long bfd_vma;
  87. typedef unsigned long bfd_offset;
  88. typedef unsigned long bfd_word;
  89. typedef unsigned long bfd_size;
  90. typedef unsigned long symvalue;
  91. typedef unsigned long bfd_size_type;
  92. #define printf_vma(x)     printf(    "%08lx", x)
  93. #define fprintf_vma(s,x) fprintf(s, "%08lx", x)
  94. #endif
  95.  
  96. typedef unsigned int flagword;    /* 32 bits of flags */
  97.  
  98. /** File formats */
  99.  
  100. typedef enum bfd_format {
  101.           bfd_unknown = 0,    /* file format is unknown */
  102.           bfd_object,    /* linker/assember/compiler output */
  103.           bfd_archive,    /* object archive file */
  104.           bfd_core,        /* core dump */
  105.           bfd_type_end}    /* marks the end; don't use it! */
  106.          bfd_format;
  107.  
  108. /* Object file flag values */
  109. #define NO_FLAGS    0
  110. #define HAS_RELOC   001
  111. #define EXEC_P      002
  112. #define HAS_LINENO  004
  113. #define HAS_DEBUG   010
  114. #define HAS_SYMS    020
  115. #define HAS_LOCALS  040
  116. #define DYNAMIC     0100
  117. #define WP_TEXT     0200
  118. #define D_PAGED     0400
  119.  
  120.  
  121. /* symbols and relocation */
  122.  
  123. typedef unsigned long symindex;
  124.  
  125. #define BFD_NO_MORE_SYMBOLS ((symindex) ~0)
  126.  
  127. typedef enum bfd_symclass {
  128.           bfd_symclass_unknown = 0,
  129.           bfd_symclass_fcommon, /* fortran common symbols */
  130.           bfd_symclass_global, /* global symbol, what a surprise */
  131.           bfd_symclass_debugger, /* some debugger symbol */
  132.           bfd_symclass_undefined /* none known */
  133.         } symclass;
  134.  
  135.  
  136. typedef int symtype;        /* Who knows, yet? */
  137.  
  138.  
  139. /* general purpose part of a symbol;
  140.    target specific parts will be found in libcoff.h, liba.out.h etc */
  141.  
  142.  
  143. #define bfd_get_section(x) ((x)->section)
  144. #define bfd_get_output_section(x) ((x)->section->output_section)
  145. #define bfd_set_section(x,y) ((x)->section) = (y)
  146. #define bfd_asymbol_base(x) ((x)->section?((x)->section->vma):0)
  147. #define bfd_asymbol_value(x) (bfd_asymbol_base(x) + x->value)
  148. #define bfd_asymbol_name(x) ((x)->name)
  149.  
  150. /* This is a type pun with struct ranlib on purpose! */
  151. typedef struct carsym {
  152.   char *name;
  153.   file_ptr file_offset;        /* look here to find the file */
  154. } carsym;            /* to make these you call a carsymogen */
  155.  
  156.   
  157. /* Used in generating armaps.  Perhaps just a forward definition would do? */
  158. struct orl {            /* output ranlib */
  159.   char **name;            /* symbol name */ 
  160.   file_ptr pos;            /* bfd* or file position */
  161.   int namidx;            /* index into string table */
  162. };
  163.  
  164.  
  165.  
  166. /* Linenumber stuff */
  167. typedef struct lineno_cache_entry {
  168.   unsigned int line_number;    /* Linenumber from start of function*/  
  169.   union {
  170.  struct symbol_cache_entry *sym;        /* Function name */
  171.     unsigned long offset;    /* Offset into section */
  172.   } u;
  173. } alent;
  174.  
  175. /* object and core file sections */
  176.  
  177.  
  178. #define    align_power(addr, align)    \
  179.     ( ((addr) + ((1<<(align))-1)) & (-1 << (align)))
  180.  
  181. typedef struct sec *sec_ptr;
  182.  
  183. #define bfd_section_name(bfd, ptr) ((ptr)->name)
  184. #define bfd_section_size(bfd, ptr) ((ptr)->size)
  185. #define bfd_section_vma(bfd, ptr) ((ptr)->vma)
  186. #define bfd_section_alignment(bfd, ptr) ((ptr)->alignment_power)
  187. #define bfd_get_section_flags(bfd, ptr) ((ptr)->flags)
  188. #define bfd_get_section_userdata(bfd, ptr) ((ptr)->userdata)
  189.  
  190. #define bfd_set_section_vma(bfd, ptr, val) (((ptr)->vma = (val)), true)
  191. #define bfd_set_section_alignment(bfd, ptr, val) (((ptr)->alignment_power = (val)),true)
  192. #define bfd_set_section_userdata(bfd, ptr, val) (((ptr)->userdata = (val)),true)
  193.  
  194. typedef struct stat stat_type; 
  195.  
  196. /** Error handling */
  197.  
  198. typedef enum bfd_error {
  199.           no_error = 0, system_call_error, invalid_target,
  200.           wrong_format, invalid_operation, no_memory,
  201.           no_symbols, no_relocation_info,
  202.           no_more_archived_files, malformed_archive,
  203.           symbol_not_found, file_not_recognized,
  204.           file_ambiguously_recognized, no_contents,
  205.         bfd_error_nonrepresentable_section,
  206.           invalid_error_code} bfd_ec;
  207.  
  208. extern bfd_ec bfd_error;
  209.  
  210. typedef struct bfd_error_vector {
  211.   PROTO(void,(* nonrepresentable_section ),(CONST bfd  *CONST abfd,
  212.                         CONST char *CONST name));
  213. } bfd_error_vector_type;
  214.  
  215. PROTO (char *, bfd_errmsg, ());
  216. PROTO (void, bfd_perror, (CONST char *message));
  217.  
  218.  
  219. typedef enum bfd_print_symbol
  220.   bfd_print_symbol_name_enum,
  221.   bfd_print_symbol_type_enum,
  222.   bfd_print_symbol_all_enum
  223. } bfd_print_symbol_enum_type;
  224.     
  225.  
  226.  
  227. /* The code that implements targets can initialize a jump table with this
  228.    macro.  It must name all its routines the same way (a prefix plus
  229.    the standard routine suffix), or it must #define the routines that
  230.    are not so named, before calling JUMP_TABLE in the initializer.  */
  231.  
  232. /* Semi-portable string concatenation in cpp */
  233. #ifndef CAT
  234. #ifdef __STDC__
  235. #define CAT(a,b) a##b
  236. #else
  237. #define CAT(a,b) a/**/b
  238. #endif
  239. #endif
  240.  
  241. #define JUMP_TABLE(NAME)\
  242. CAT(NAME,_core_file_failing_command),\
  243. CAT(NAME,_core_file_failing_signal),\
  244. CAT(NAME,_core_file_matches_executable_p),\
  245. CAT(NAME,_slurp_armap),\
  246. CAT(NAME,_slurp_extended_name_table),\
  247. CAT(NAME,_truncate_arname),\
  248. CAT(NAME,_write_armap),\
  249. CAT(NAME,_close_and_cleanup),    \
  250. CAT(NAME,_set_section_contents),\
  251. CAT(NAME,_get_section_contents),\
  252. CAT(NAME,_new_section_hook),\
  253. CAT(NAME,_get_symtab_upper_bound),\
  254. CAT(NAME,_get_symtab),\
  255. CAT(NAME,_get_reloc_upper_bound),\
  256. CAT(NAME,_canonicalize_reloc),\
  257. CAT(NAME,_make_empty_symbol),\
  258. CAT(NAME,_print_symbol),\
  259. CAT(NAME,_get_lineno),\
  260. CAT(NAME,_set_arch_mach),\
  261. CAT(NAME,_openr_next_archived_file),\
  262. CAT(NAME,_find_nearest_line),\
  263. CAT(NAME,_generic_stat_arch_elt),\
  264. CAT(NAME,_sizeof_headers),\
  265. CAT(NAME,_bfd_debug_info_start),\
  266. CAT(NAME,_bfd_debug_info_end),\
  267. CAT(NAME,_bfd_debug_info_accumulate)
  268.  
  269. #define COFF_SWAP_TABLE coff_swap_aux_in, coff_swap_sym_in, coff_swap_lineno_in,
  270.  
  271. /* User program access to BFD facilities */
  272.  
  273. extern CONST short _bfd_host_big_endian;
  274. #define HOST_BYTE_ORDER_BIG_P    (*(char *)&_bfd_host_big_endian)
  275.  
  276. /* The bfd itself */
  277.  
  278. /* Cast from const char * to char * so that caller can assign to
  279.    a char * without a warning.  */
  280. #define bfd_get_filename(abfd) ((char *) (abfd)->filename)
  281. #define bfd_get_format(abfd) ((abfd)->format)
  282. #define bfd_get_target(abfd) ((abfd)->xvec->name)
  283. #define bfd_get_file_flags(abfd) ((abfd)->flags)
  284. #define bfd_applicable_file_flags(abfd) ((abfd)->xvec->object_flags)
  285. #define bfd_applicable_section_flags(abfd) ((abfd)->xvec->section_flags)
  286. #define bfd_my_archive(abfd) ((abfd)->my_archive);
  287. #define bfd_has_map(abfd) ((abfd)->has_armap)
  288. #define bfd_header_twiddle_required(abfd) \
  289.         ((((abfd)->xvec->header_byteorder_big_p)        \
  290.       != (boolean)HOST_BYTE_ORDER_BIG_P) ? true:false)
  291.  
  292. #define bfd_valid_reloc_types(abfd) ((abfd)->xvec->valid_reloc_types)
  293. #define bfd_usrdata(abfd) ((abfd)->usrdata)
  294.  
  295. #define bfd_get_start_address(abfd) ((abfd)->start_address)
  296. #define bfd_get_symcount(abfd) ((abfd)->symcount)
  297. #define bfd_get_outsymbols(abfd) ((abfd)->outsymbols)
  298. #define bfd_count_sections(abfd) ((abfd)->section_count)
  299. #define bfd_get_architecture(abfd) ((abfd)->obj_arch)
  300. #define bfd_get_machine(abfd) ((abfd)->obj_machine)
  301.  
  302.  
  303.  
  304. #define BYTE_SIZE 1
  305. #define SHORT_SIZE 2
  306. #define LONG_SIZE 4
  307.  
  308.  
  309.  
  310. /*THE FOLLOWING IS EXTRACTED FROM THE SOURCE */
  311.  
  312. /* Opens the file supplied (using fopen) with the target supplied, it
  313. returns a pointer to the created bfd.
  314.  
  315. If NULL is returned then an error has occured.
  316. Possible errors are no_memory, invalid_target or system_call error.
  317. */
  318. PROTO(bfd*, bfd_openr, (CONST char *filename,CONST char*target));
  319. /* bfd_fdopenr is to bfd_fopenr much like  fdopen is to fopen. It opens a bfd on
  320. a file already described by the @var{fd} supplied. 
  321.  
  322. Possible errors are no_memory, invalid_target and system_call error.
  323. */
  324.  PROTO(bfd *, bfd_fdopenr,
  325.     (CONST char *filename, CONST char *target, int fd));
  326. /* Creates a bfd, associated with file @var{filename}, using the file
  327. format @var{target}, and returns a pointer to it.
  328.  
  329. Possible errors are system_call_error, no_memory, invalid_target.
  330. */
  331. PROTO(bfd *, bfd_openw, (CONST char *filename, CONST char *target));
  332. /* This function closes a bfd. If the bfd was open for writing, then
  333. pending operations are completed and the file written out and closed.
  334. If the created file is executable, then @code{chmod} is called to mark
  335. it as such.
  336.  
  337. All memory attatched to the bfd's obstacks is released. 
  338.  
  339. @code{true} is returned if all is ok, otherwise @code{false}.
  340. */
  341. PROTO(boolean, bfd_close,(bfd *));
  342. /* This routine creates a new bfd in the manner of bfd_openw, but without
  343. opening a file. The new bfd takes the target from the target used by
  344. @var{template}. The format is always set to @code{bfd_object}.
  345.  
  346. */
  347. PROTO(bfd *, bfd_create, (CONST char *filename, bfd *template));
  348. /* Return the number of bytes in the obstacks connected to the supplied
  349. bfd.
  350. */
  351. PROTO(bfd_size_type,bfd_alloc_size,(bfd *abfd));
  352. /* This enum gives the object file's CPU
  353. architecture, in a global sense.  E.g. what processor family does it
  354. belong to?  There is another field, which indicates what processor
  355. within the family is in use.  The machine gives a number which
  356. distingushes different versions of the architecture, containing for
  357. example 2 and 3 for Intel i960 KA and i960 KB, and 68020 and 68030 for
  358. Motorola 68020 and 68030.
  359.  
  360. */
  361. enum bfd_architecture 
  362. {
  363.   bfd_arch_unknown,   /* File arch not known */
  364.   bfd_arch_obscure,   /* Arch known, not one of these */
  365.   bfd_arch_m68k,      /* Motorola 68xxx */
  366.   bfd_arch_vax,       /* DEC Vax */   
  367.   bfd_arch_i960,      /* Intel 960 */
  368.     /* The order of the following is important.
  369.        lower number indicates a machine type that 
  370.        only accepts a subset of the instructions
  371.        available to machines with higher numbers.
  372.        The exception is the "ca", which is
  373.        incompatible with all other machines except 
  374.        "core". */
  375.  
  376. #define bfd_mach_i960_core      1
  377. #define bfd_mach_i960_ka_sa     2
  378. #define bfd_mach_i960_kb_sb     3
  379. #define bfd_mach_i960_mc        4
  380. #define bfd_mach_i960_xa        5
  381. #define bfd_mach_i960_ca        6
  382.  
  383.   bfd_arch_a29k,      /* AMD 29000 */
  384.   bfd_arch_sparc,     /* SPARC */
  385.   bfd_arch_mips,      /* MIPS Rxxxx */
  386.   bfd_arch_i386,      /* Intel 386 */
  387.   bfd_arch_ns32k,     /* National Semiconductor 32xxx */
  388.   bfd_arch_tahoe,     /* CCI/Harris Tahoe */
  389.   bfd_arch_i860,      /* Intel 860 */
  390.   bfd_arch_romp,      /* IBM ROMP RS/6000 */
  391.   bfd_arch_alliant,   /* Alliant */
  392.   bfd_arch_convex,    /* Convex */
  393.   bfd_arch_m88k,      /* Motorola 88xxx */
  394.   bfd_arch_pyramid,   /* Pyramid Technology */
  395.   bfd_arch_h8_300,    /* Hitachi H8/300 */
  396.   bfd_arch_last
  397.   };
  398.  
  399. /* stuff
  400. */
  401.  
  402. /* Return a printable string representing the architecture and machine
  403. type. The result is only good until the next call to
  404. bfd_printable_arch_mach.  
  405. */
  406. PROTO(CONST char *,bfd_printable_arch_mach,
  407.     (enum bfd_architecture arch, unsigned long machine));
  408. /* Scan a string and attempt to turn it into an archive and machine type combination.  
  409. */
  410. PROTO(boolean, bfd_scan_arch_mach,
  411.     (CONST char *, enum bfd_architecture *, unsigned long *));
  412. /* This routine is used to determine whether two BFDs' architectures and machine types are
  413. compatible.  It calculates the lowest common denominator between the
  414. two architectures and machine types implied by the bfds and sets the
  415. objects pointed at by @var{archp} and @var{machine} if non NULL. 
  416.  
  417. This routine returns @code{true} if the bfds are of compatible type,
  418. otherwise @code{false}.
  419. */
  420. PROTO(boolean, bfd_arch_compatible,
  421.      (bfd *abfd,
  422.      bfd *bbfd,
  423.      enum bfd_architecture *archp,
  424.      unsigned long *machinep));
  425. /* Set atch mach
  426. */
  427. #define bfd_set_arch_mach(abfd, arch, mach) \
  428.      BFD_SEND (abfd, _bfd_set_arch_mach,\
  429.                     (abfd, arch, mach))
  430.  
  431. /* These macros as used for reading and writing raw data in sections;
  432. each access (except for bytes) is vectored through the target format
  433. of the bfd and mangled accordingly. The mangling performs any
  434. necessary endian translations and removes alignment restrictions.
  435. */
  436. #define bfd_put_8(abfd, val, ptr) \
  437.                 (*((char *)ptr) = (char)val)
  438. #define bfd_get_8(abfd, ptr) \
  439.                 (*((char *)ptr))
  440. #define bfd_put_16(abfd, val, ptr) \
  441.                 BFD_SEND(abfd, bfd_putx16, (val,ptr))
  442. #define bfd_get_16(abfd, ptr) \
  443.                 BFD_SEND(abfd, bfd_getx16, (ptr))
  444. #define bfd_put_32(abfd, val, ptr) \
  445.                 BFD_SEND(abfd, bfd_putx32, (val,ptr))
  446. #define bfd_get_32(abfd, ptr) \
  447.                 BFD_SEND(abfd, bfd_getx32, (ptr))
  448. #define bfd_put_64(abfd, val, ptr) \
  449.                 BFD_SEND(abfd, bfd_putx64, (val, ptr))
  450. #define bfd_get_64(abfd, ptr) \
  451.                 BFD_SEND(abfd, bfd_getx64, (ptr))
  452.  
  453. /* These macros have the same function as their @code{bfd_get_x}
  454. bretherin, except that they are used for removing information for the
  455. header records of object files. Believe it or not, some object files
  456. keep their header records in big endian order, and their data in little
  457. endan order.
  458. */
  459. #define bfd_h_put_8(abfd, val, ptr) \
  460.                 (*((char *)ptr) = (char)val)
  461. #define bfd_h_get_8(abfd, ptr) \
  462.                 (*((char *)ptr))
  463. #define bfd_h_put_16(abfd, val, ptr) \
  464.                 BFD_SEND(abfd, bfd_h_putx16,(val,ptr))
  465. #define bfd_h_get_16(abfd, ptr) \
  466.                 BFD_SEND(abfd, bfd_h_getx16,(ptr))
  467. #define bfd_h_put_32(abfd, val, ptr) \
  468.                 BFD_SEND(abfd, bfd_h_putx32,(val,ptr))
  469. #define bfd_h_get_32(abfd, ptr) \
  470.                 BFD_SEND(abfd, bfd_h_getx32,(ptr))
  471. #define bfd_h_put_64(abfd, val, ptr) \
  472.                 BFD_SEND(abfd, bfd_h_putx64,(val, ptr))
  473. #define bfd_h_get_64(abfd, ptr) \
  474.                 BFD_SEND(abfd, bfd_h_getx64,(ptr))
  475.  
  476. /* The shape of a section struct:
  477.  
  478. */
  479. typedef struct sec {
  480.  
  481.     /* The name of the section, the name isn't a copy, the pointer is
  482.     the same as that passed to bfd_make_section.
  483.     */
  484.     CONST char *name;
  485.  
  486.     /* The next section in the list belonging to the bfd, or NULL.
  487.     */
  488.     struct sec *next;
  489.  
  490.     /* The field flags contains attributes of the section. Some of these
  491.     flags are read in from the object file, and some are synthesized from
  492.     other information. 
  493.     */
  494. flagword flags;
  495. #define SEC_NO_FLAGS   0x000
  496.  
  497.     /* Tells the OS to allocate space for this section when loaded.
  498.     This would clear for a section containing debug information only.
  499.     */
  500. #define SEC_ALLOC      0x001
  501.  
  502.     /* Tells the OS to load the section from the file when loading.
  503.     This would be clear for a .bss section 
  504.     */
  505. #define SEC_LOAD       0x002
  506.  
  507.     /* The section contains data still to be relocated, so there will be some
  508.     relocation information too.
  509.     */
  510. #define SEC_RELOC      0x004
  511.  
  512.     /* Obsolete ? 
  513.     */
  514. #define SEC_BALIGN     0x008
  515.  
  516.     /* A signal to the OS that the section contains read only data.
  517.     */
  518. #define SEC_READONLY   0x010
  519.  
  520.     /* The section contains code only.
  521.     */
  522. #define SEC_CODE       0x020
  523.  
  524.     /* The section contains data only.
  525.     */
  526. #define SEC_DATA        0x040
  527.  
  528.     /* The section will reside in ROM.
  529.     */
  530. #define SEC_ROM        0x080
  531.  
  532.     /* The section contains constructor information. This section type is
  533.     used by the linker to create lists of constructors and destructors
  534.     used by @code{g++}. When a back end sees a symbol which should be used
  535.     in a constructor list, it creates a new section for the type of name
  536.     (eg @code{__CTOR_LIST__}), attatches the symbol to it and builds a
  537.     relocation. To build the lists of constructors, all the linker has to
  538.     to is catenate all the sections called @code{__CTOR_LIST__} and
  539.     relocte the data contained within - exactly the operations it would
  540.     peform on standard data.
  541.     */
  542. #define SEC_CONSTRUCTOR 0x100
  543.  
  544.     /* The section has contents - a bss section could be
  545.     @code{SEC_ALLOC} | @code{SEC_HAS_CONTENTS}, a debug section could be
  546.     @code{SEC_HAS_CONTENTS}
  547.     */
  548. #define SEC_HAS_CONTENTS 0x200
  549.  
  550.     /* An instruction to the linker not to output sections containing
  551.     this flag even if they have information which would normally be written.
  552.     */
  553. #define SEC_NEVER_LOAD 0x400
  554.  
  555.     /* The base address of the section in the address space of the target.
  556.     */
  557.    bfd_vma vma;
  558.  
  559.     /* The size of the section in bytes of the loaded section. This contains
  560.     a value even if the section has no contents (eg, the size of @code{.bss}).
  561.     */
  562.    bfd_size_type size;    
  563.  
  564.     /* If this section is going to be output, then this value is the
  565.     offset into the output section of the first byte in the input
  566.     section. Eg, if this was going to start at the 100th byte in the
  567.     output section, this value would be 100. 
  568.     */
  569.    bfd_vma output_offset;
  570.  
  571.     /* The output section through which to map on output.
  572.     */
  573.    struct sec *output_section;
  574.  
  575.     /* The alignment requirement of the section, as an exponent - eg 3
  576.     aligns to 2^3 (or 8) 
  577.     */
  578.    unsigned int alignment_power;
  579.  
  580.     /* If an input section, a pointer to a vector of relocation records for
  581.     the data in this section.
  582.     */
  583.    struct reloc_cache_entry *relocation;
  584.  
  585.     /* If an output section, a pointer to a vector of pointers to
  586.     relocation records for the data in this section.
  587.     */
  588.    struct reloc_cache_entry **orelocation;
  589.  
  590.     /* The number of relocation records in one of the above 
  591.     */
  592.    unsigned reloc_count;
  593.  
  594.     /* Which section is it 0..nth     
  595.     */
  596.    int index;                      
  597.  
  598.     /* Information below is back end specific - and not always used or
  599.     updated 
  600.     
  601.     File position of section data   
  602.     */
  603.    file_ptr filepos;      
  604.  
  605.     /* File position of relocation info        
  606.     */
  607.    file_ptr rel_filepos;
  608.  
  609.     /* File position of line data              
  610.     */
  611.    file_ptr line_filepos;
  612.  
  613.     /* Pointer to data for applications        
  614.     */
  615.    PTR userdata;
  616.    struct lang_output_section *otheruserdata;
  617.  
  618.     /* Attached line number information        
  619.     */
  620.    alent *lineno;
  621.  
  622.     /* Number of line number records   
  623.     */
  624.    unsigned int lineno_count;
  625.  
  626.     /* When a section is being output, this value changes as more
  627.     linenumbers are written out 
  628.     */
  629.    file_ptr moving_line_filepos;
  630.  
  631.     /* what the section number is in the target world 
  632.     */
  633.    unsigned int target_index;
  634.    PTR used_by_bfd;
  635.  
  636.     /* If this is a constructor section then here is a list of the
  637.     relocations created to relocate items within it.
  638.     */
  639.    struct relent_chain *constructor_chain;
  640.  
  641.     /* The bfd which owns the section.
  642.     */
  643.    bfd *owner;
  644. } asection ;
  645.  
  646. /* Runs through the provided @var{abfd} and returns the @code{asection}
  647. who's name matches that provided, otherwise NULL. @xref{Sections}, for more information.
  648.  
  649. */
  650. PROTO(asection *, bfd_get_section_by_name,
  651.     (bfd *abfd, CONST char *name));
  652. /* This function creates a new empty section called @var{name} and attatches it
  653. to the end of the chain of sections for @var{bfd}. An attempt to
  654. create a section with a name which is already in use, returns the old
  655. section by that name instead.
  656.  
  657. Possible errors are:
  658. @table @code
  659. @item invalid_operation
  660. If output has already started for this bfd.
  661. @item no_memory
  662. If obstack alloc fails.
  663. @end table
  664.  
  665. */
  666. PROTO(asection *, bfd_make_section, (bfd *, CONST char *name));
  667. /* Attempts to set the attributes of the section named in the bfd
  668. supplied to the value. Returns true on success, false on error.
  669. Possible error returns are:
  670. @table @code
  671. @item invalid operation
  672. The section cannot have one or more of the attributes requested. For
  673. example, a .bss section in @code{a.out} may not have the
  674. @code{SEC_HAS_CONTENTS} field set.
  675. @end table
  676.  
  677. */
  678. PROTO(boolean, bfd_set_section_flags,
  679.        (bfd *, asection *, flagword));
  680. /* Calls the provided function @var{func} for each section attatched to
  681. the bfd @var{abfd}, passing @var{obj} as an argument. The function
  682. will be called as if by 
  683.  
  684. @example
  685.   func(abfd, the_section, obj);
  686. @end example
  687.  
  688.  
  689. */
  690. PROTO(void, bfd_map_over_sections,
  691.             (bfd *abfd, void (*func)(), PTR obj));
  692. /* This is the prefered method for iterating over sections, an
  693. alternative would be to use a loop:
  694.  
  695. @example
  696.    section *p;
  697.    for (p = abfd->sections; p != NULL; p = p->next)
  698.       func(abfd, p, ...)
  699. @end example*/
  700.  
  701. /* Sets @var{section} to the size @var{val}. If the operation is ok, then
  702. @code{true} is returned, else @code{false}. 
  703.  
  704. Possible error returns:
  705. @table @code
  706. @item invalid_operation
  707. Writing has started to the bfd, so setting the size is invalid
  708. @end table 
  709.  
  710. */
  711. PROTO(boolean, bfd_set_section_size,
  712.      (bfd *, asection *, bfd_size_type val));
  713. /* Sets the contents of the section @var{section} in bfd @var{abfd} to
  714. the data starting in memory at @var{data}. The data is written to the
  715. output section starting at offset @var{offset} for @var{count} bytes.
  716.  
  717. Normally @code{true} is returned, else @code{false}. Possible error
  718. returns are:
  719. @table @code
  720. @item no_contents
  721. The output section does not have the @code{SEC_HAS_CONTENTS}
  722. attribute, so nothing can be written to it.
  723. @item and some more too
  724. @end table
  725. This routine is front end to the back end function @code{_bfd_set_section_contents}.
  726.  
  727. */
  728. PROTO(boolean, bfd_set_section_contents,
  729.          (bfd *abfd,        
  730.          asection *section,
  731.          PTR data,
  732.          file_ptr offset,
  733.          bfd_size_type count));
  734. /* This function reads data from @var{section} in bfd @var{abfd} into
  735. memory starting at @var{location}. The data is read at an offset of
  736. @var{offset} from the start of the input section, and is read for
  737. @var{count} bytes.
  738.  
  739. If the contents of a constuctor with the @code{SEC_CONSTUCTOR} flag
  740. set are requested, then the @var{location} is filled with zeroes.
  741.  
  742. If no errors occur, @code{true} is returned, else @code{false}.
  743. Possible errors are:
  744.  
  745. @table @code
  746. @item unknown yet
  747. @end table
  748.  
  749. */
  750. PROTO(boolean, bfd_get_section_contents, 
  751.         (bfd *abfd, asection *section, PTR location,
  752.          file_ptr offset, bfd_size_type count));
  753. /* @subsection typedef asymbol
  754. An @code{asymbol} has the form:
  755.  
  756. */
  757. typedef struct symbol_cache_entry 
  758. {
  759.  
  760.     /* A pointer to the bfd which owns the symbol. This information is
  761.     necessary so that a back end can work out what additional (invisible to
  762.     the application writer) information is carried with the symbol. 
  763.     */
  764.   struct _bfd *the_bfd;
  765.  
  766.     /* The text of the symbol. The name is left alone, and not copied - the
  767.     application may not alter it. 
  768.     */
  769.    CONST char *name;
  770.  
  771.     /* The value of the symbol.
  772.     */
  773.    symvalue value;
  774.  
  775.     /* Attributes of a symbol:
  776.     */
  777. #define BSF_NO_FLAGS    0x00
  778.  
  779.     /* The symbol has local scope; @code{static} in @code{C}. The value is
  780.     the offset into the section of the data.
  781.     */
  782. #define BSF_LOCAL    0x01
  783.  
  784.     /* The symbol has global scope; initialized data in @code{C}. The value
  785.     is the offset into the section of the data.
  786.     */
  787. #define BSF_GLOBAL    0x02
  788.  
  789.     /* Obsolete
  790.     */
  791. #define BSF_IMPORT    0x04
  792.  
  793.     /* The symbol has global scope, and is exported. The value is the offset
  794.     into the section of the data.
  795.     */
  796. #define BSF_EXPORT    0x08
  797.  
  798.     /* The symbol is undefined. @code{extern} in @code{C}. The value has no meaning.
  799.     */
  800. #define BSF_UNDEFINED    0x10    
  801.  
  802.     /* The symbol is common, initialized to zero; default in @code{C}. The
  803.     value is the size of the object in bytes.
  804.     */
  805. #define BSF_FORT_COMM    0x20    
  806.  
  807.     /* A normal @code{C} symbol would be one of:
  808.     @code{BSF_LOCAL}, @code{BSF_FORT_COMM},  @code{BSF_UNDEFINED} or @code{BSF_EXPORT|BSD_GLOBAL}
  809.     
  810.     The symbol is a debugging record. The value has an arbitary meaning.
  811.     */
  812. #define BSF_DEBUGGING    0x40
  813.  
  814.     /* The symbol has no section attached, any value is the actual value and
  815.     is not a relative offset to a section.
  816.     */
  817. #define BSF_ABSOLUTE    0x80
  818.  
  819.     /* Used by the linker
  820.     */
  821. #define BSF_KEEP        0x10000
  822. #define BSF_WARNING     0x20000
  823. #define BSF_KEEP_G      0x80000
  824.  
  825.     /* Unused
  826.     */
  827. #define BSF_WEAK        0x100000
  828. #define BSF_CTOR        0x200000 
  829. #define BSF_FAKE        0x400000 
  830.  
  831.     /* The symbol used to be a common symbol, but now it is allocated.
  832.     */
  833. #define BSF_OLD_COMMON  0x800000  
  834.  
  835.     /* The default value for common data.
  836.     */
  837. #define BFD_FORT_COMM_DEFAULT_VALUE 0
  838.  
  839.     /* In some files the type of a symbol sometimes alters its location
  840.     in an output file - ie in coff a @code{ISFCN} symbol which is also @code{C_EXT}
  841.     symbol appears where it was declared and not at the end of a section. 
  842.     This bit is set by the target bfd part to convey this information. 
  843.     */
  844. #define BSF_NOT_AT_END    0x40000
  845.   flagword flags;
  846.  
  847.     /* Aointer to the section to which this symbol is relative, or 0 if the
  848.     symbol is absolute or undefined. Note that it is not sufficient to set
  849.     this location to 0 to mark a symbol as absolute - the flag
  850.     @code{BSF_ABSOLUTE} must be set also.
  851.     */
  852.   struct sec *section;
  853.  
  854.     /* Back end special data. This is being phased out in favour of making
  855.     this a union.
  856.     */
  857.   PTR udata;    
  858. } asymbol;
  859.  
  860. /* Returns the number of bytes required in a vector of pointers to
  861. @code{asymbols} for all the symbols in the supplied bfd, including a
  862. terminal NULL pointer. If there are no symbols in the bfd, then 0 is
  863. returned.
  864. */
  865. #define get_symtab_upper_bound(abfd) \
  866.      BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))
  867.  
  868. /* Supplied a bfd and a pointer to an uninitialized vector of pointers.
  869. This reads in the symbols from the bfd, and fills in the table with
  870. pointers to the symbols, and a trailing NULL. The routine returns the
  871. actual number of symbol pointers not including the NULL.
  872.  
  873. */
  874. #define bfd_canonicalize_symtab(abfd, location) \
  875.      BFD_SEND (abfd, _bfd_canonicalize_symtab,\
  876.                   (abfd, location))
  877.  
  878.  
  879. /* Provided a table of pointers to to symbols and a count, writes to the
  880. output bfd the symbols when closed.
  881.  
  882. */
  883. PROTO(boolean, bfd_set_symtab, (bfd *, asymbol **, unsigned int ));
  884. /* Prints the value and flags of the symbol supplied to the stream file.
  885.  
  886. */
  887. PROTO(void, bfd_print_symbol_vandf, (PTR file, asymbol *symbol));
  888. /* This function creates a new @code{asymbol} structure for the bfd, and
  889. returns a pointer to it.
  890.  
  891. This routine is necessary, since each back end has private information
  892. surrounding the @code{asymbol}. Building your own @code{asymbol} and
  893. pointing to it will not create the private information, and will cause
  894. problems later on.
  895. */
  896. #define bfd_make_empty_symbol(abfd) \
  897.      BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))
  898.  
  899. /* @section typedef bfd
  900.  
  901. Pointers to bfd structs are the cornerstone of any application using
  902. libbfd. References though the bfd and to data in the bfd give the
  903. entire bfd functionality.
  904.  
  905. Finally!  The BFD struct itself.  This contains the major data about
  906. the file, and contains pointers to the rest of the data.
  907.  
  908. */
  909. struct _bfd 
  910. {
  911.  
  912.     /*   The filename the application opened the bfd with.
  913.     */
  914.   CONST char *filename;                
  915.  
  916.     /* A pointer to the target jump table.
  917.     */
  918.   struct bfd_target *xvec;
  919.  
  920.     /* To avoid dragging too many header files into every file that
  921.     includes bfd.h, IOSTREAM has been declared as a "char *", and MTIME
  922.     as a "long".  Their correct types, to which they are cast when used,
  923.     are "FILE *" and "time_t".  
  924.     
  925.     The iostream is the result of an fopen on the filename.
  926.     */
  927.   char *iostream;
  928.  
  929.     /* Is the file being cached @xref{File Caching}.
  930.     */
  931.   boolean cacheable;
  932.  
  933.     /* Marks whether there was a default target specified when the bfd was
  934.     opened. This is used to select what matching algorithm to use to chose
  935.     the back end.
  936.     */
  937.   boolean target_defaulted;
  938.  
  939.     /* The caching routines use these to maintain an LRU list of bfds.
  940.     */
  941.   struct _bfd *lru_prev, *lru_next;
  942.  
  943.     /* When a file is closed by the caching routines, it retains the state
  944.     here:
  945.     */
  946.   file_ptr where;              
  947.  
  948.     /* and here:
  949.     */
  950.   boolean opened_once;
  951.   boolean mtime_set;
  952.  
  953.     /* File modified time 
  954.     */
  955.   long mtime;          
  956.  
  957.     /* For output files, channel we locked (is this used?).
  958.     */
  959. int ifd;
  960.  
  961.     /* The format which belongs to the bfd.
  962.     */
  963.   bfd_format format;
  964.  
  965.     /* The direction the bfd was opened with
  966.     */
  967.   enum bfd_direction {no_direction = 0,
  968.                        read_direction = 1,
  969.                        write_direction = 2,
  970.                        both_direction = 3} direction;
  971.  
  972.     /* Format_specific flags
  973.     */
  974.   flagword flags;              
  975.  
  976.     /* Currently my_archive is tested before adding origin to anything. I
  977.     believe that this can become always an add of origin, with origin set
  978.     to 0 for non archive files.  
  979.     */
  980.   file_ptr origin;             
  981.  
  982.     /* Remember when output has begun, to stop strange things happening.
  983.     */
  984.   boolean output_has_begun;
  985.  
  986.     /* Pointer to linked list of sections
  987.     */
  988.   struct sec  *sections;
  989.  
  990.     /* The number of sections 
  991.     */
  992.   unsigned int section_count;
  993.  
  994.     /* Stuff only usefull for object files:
  995.     The start address.
  996.     */
  997.   bfd_vma start_address;
  998.  
  999.     /* Used for input and output
  1000.     */
  1001.   unsigned int symcount;
  1002.  
  1003.     /* Symtab for output bfd
  1004.     */
  1005.   struct symbol_cache_entry  **outsymbols;             
  1006.  
  1007.     /* Architecture of object machine, eg m68k 
  1008.     */
  1009.   enum bfd_architecture obj_arch;
  1010.  
  1011.     /* Particular machine within arch, e.g. 68010
  1012.     */
  1013.   unsigned long obj_machine;
  1014.  
  1015.     /* Stuff only usefull for archives:
  1016.     */
  1017.   PTR arelt_data;              
  1018.   struct _bfd *my_archive;     
  1019.   struct _bfd *next;           
  1020.   struct _bfd *archive_head;   
  1021.   boolean has_armap;           
  1022.  
  1023.     /* Used by the back end to hold private data.
  1024.     */
  1025.   PTR tdata;
  1026.  
  1027.     /* Used by the application to hold private data
  1028.     */
  1029.   PTR usrdata;
  1030.  
  1031.     /* Where all the allocated stuff under this BFD goes 
  1032.     */
  1033.   struct obstack memory;
  1034. };
  1035.  
  1036. /* Marks the entry point of an output bfd. Returns @code{true} on
  1037. success, @code{false} otherwise.
  1038.  
  1039. */
  1040. PROTO(boolean, bfd_set_start_address,(bfd *, bfd_vma));
  1041. /* Return cached file modification time (e.g. as read from archive header
  1042. for archive members, or from file system if we have been called
  1043. before); else determine modify time, cache it, and return it.  
  1044.  
  1045. */
  1046. PROTO(long, bfd_get_mtime, (bfd *));
  1047. #define bfd_sizeof_headers(abfd, reloc) \
  1048.      BFD_SEND (abfd, _bfd_sizeof_headers, (abfd, reloc))
  1049.  
  1050. #define bfd_find_nearest_line(abfd, section, symbols, offset, filename_ptr, func, line_ptr) \
  1051.      BFD_SEND (abfd, _bfd_find_nearest_line,  (abfd, section, symbols, offset, filename_ptr, func, line_ptr))
  1052.  
  1053. #define bfd_debug_info_start(abfd) \
  1054.         BFD_SEND (abfd, _bfd_debug_info_start, (abfd))
  1055.  
  1056. #define bfd_debug_info_end(abfd) \
  1057.         BFD_SEND (abfd, _bfd_debug_info_end, (abfd))
  1058.  
  1059. #define bfd_debug_info_accumulate(abfd, section) \
  1060.         BFD_SEND (abfd, _bfd_debug_info_accumulate, (abfd, section))
  1061.  
  1062. #define bfd_stat_arch_elt(abfd, stat) \
  1063.         BFD_SEND (abfd, _bfd_stat_arch_elt,(abfd, stat))
  1064.  
  1065. #define bfd_coff_swap_aux_in(a,e,t,c,i) \
  1066.         BFD_SEND (a, _bfd_coff_swap_aux_in, (a,e,t,c,i))
  1067.  
  1068. #define bfd_coff_swap_sym_in(a,e,i) \
  1069.         BFD_SEND (a, _bfd_coff_swap_sym_in, (a,e,i))
  1070.  
  1071. #define bfd_coff_swap_lineno_in(a,e,i) \
  1072.         BFD_SEND ( a, _bfd_coff_swap_lineno_in, (a,e,i))
  1073.  
  1074. /* What this does
  1075. */
  1076. PROTO(symindex, bfd_get_next_mapent, (bfd *, symindex, carsym **));
  1077. /* Used whilst processing archives. Sets the head of the chain of bfds
  1078. contained in an archive to @var{new_head}. (see chapter on archives)
  1079. */
  1080. PROTO(boolean, bfd_set_archive_head, (bfd *output, bfd *new_head));
  1081.  
  1082. PROTO(bfd *, bfd_get_elt_at_index, (bfd *, int));
  1083.  
  1084.  
  1085. /* Initially provided a bfd containing an archive and NULL, opens a bfd
  1086. on the first contained element and returns that. Subsequent calls to
  1087. bfd_openr_next_archived_file should pass the archive and the previous
  1088. return value to return a created bfd to the next contained element.
  1089. NULL is returned when there are no more.
  1090.  
  1091. */
  1092. PROTO(bfd*, bfd_openr_next_archived_file,
  1093.                (bfd *archive, bfd *previous));
  1094. /* Returns a read-only string explaining what program was running when
  1095. it failed and produced the core file being read
  1096.  
  1097. */
  1098. PROTO(CONST char *, bfd_core_file_failing_command, (bfd *));
  1099. /* Returns the signal number which caused the core dump which generated
  1100. the file the bfd is attatched to.
  1101.  
  1102. */
  1103. PROTO(int, bfd_core_file_failing_signal, (bfd *));
  1104. /* Returns @code{true} if the core file attatched to @var{core_bfd} was
  1105. generated by a run of the executable file attatched to @var{exec_bfd},
  1106. or else @code{false}.
  1107. */
  1108. PROTO(boolean, core_file_matches_executable_p,
  1109.     (bfd *core_bfd, bfd *exec_bfd));
  1110. /* The relocation routine returns as a status an enumerated type:
  1111.  
  1112. */
  1113. typedef enum bfd_reloc_status {
  1114.  
  1115.     /* No errors detected
  1116.     */
  1117.   bfd_reloc_ok,
  1118.  
  1119.     /* The relocation was performed, but there was an overflow.
  1120.     */
  1121.   bfd_reloc_overflow,
  1122.  
  1123.     /* The address to relocate was not within the section supplied
  1124.     */
  1125.   bfd_reloc_outofrange,
  1126.  
  1127.     /* Used by special functions
  1128.     */
  1129.   bfd_reloc_continue,
  1130.  
  1131.     /* Unused 
  1132.     */
  1133.   bfd_reloc_notsupported,
  1134.  
  1135.     /* Unsupported relocation size requested. 
  1136.     */
  1137.   bfd_reloc_other,
  1138.  
  1139.     /* The symbol to relocate against was undefined.
  1140.     */
  1141.   bfd_reloc_undefined,
  1142.  
  1143.     /* The relocaction was performed, but may not be ok - presently generated
  1144.     only when linking i960 coff files with i960 b.out symbols.
  1145.     */
  1146.   bfd_reloc_dangerous
  1147.    }
  1148.  bfd_reloc_status_enum_type;
  1149. typedef struct reloc_cache_entry 
  1150. {
  1151.  
  1152.     /* A pointer into the canonical table of pointers 
  1153.     */
  1154.   struct symbol_cache_entry **sym_ptr_ptr;
  1155.  
  1156.     /* offset in section                 
  1157.     */
  1158.   rawdata_offset address;
  1159.  
  1160.     /* addend for relocation value        
  1161.     */
  1162.   bfd_vma addend;    
  1163.  
  1164.     /* if sym is null this is the section 
  1165.     */
  1166.   struct sec *section;
  1167.  
  1168.     /* Pointer to how to perform the required relocation
  1169.     */
  1170.   CONST struct reloc_howto_struct *howto;
  1171. } arelent;
  1172.  
  1173. /* The @code{reloc_howto_type} is a structure which contains all the
  1174. information that bfd needs to know to tie up a back end's data.
  1175.  
  1176. */
  1177. typedef CONST struct reloc_howto_struct 
  1178.  
  1179.     /* The type field has mainly a documetary use - the back end can to what
  1180.     it wants with it, though the normally the back end's external idea of
  1181.     what a reloc number would be would be stored in this field. For
  1182.     example, the a PC relative word relocation in a coff environment would
  1183.     have the type 023 - because that's what the outside world calls a
  1184.     R_PCRWORD reloc.
  1185.     */
  1186.   unsigned int type;
  1187.  
  1188.     /* The value the final relocation is shifted right by. This drops
  1189.     unwanted data from the relocation. 
  1190.     */
  1191.   unsigned int rightshift;
  1192.  
  1193.     /* The size of the item to be relocated - 0, is one byte, 1 is 2 bytes, 3
  1194.     is four bytes.
  1195.     */
  1196.   unsigned int size;
  1197.  
  1198.     /* Now obsolete
  1199.     */
  1200.   unsigned int bitsize;
  1201.  
  1202.     /* Notes that the relocation is relative to the location in the data
  1203.     section of the addend. The relocation function will subtract from the
  1204.     relocation value the address of the location being relocated.
  1205.     */
  1206.   boolean pc_relative;
  1207.  
  1208.     /* Now obsolete
  1209.     */
  1210.   unsigned int bitpos;
  1211.  
  1212.     /* Now obsolete
  1213.     */
  1214.   boolean absolute;
  1215.  
  1216.     /* Causes the relocation routine to return an error if overflow is
  1217.     detected when relocating.
  1218.     */
  1219.   boolean complain_on_overflow;
  1220.  
  1221.     /* If this field is non null, then the supplied function is called rather
  1222.     than the normal function. This allows really strange relocation
  1223.     methods to be accomodated (eg, i960 callj instructions).
  1224.     */
  1225.   bfd_reloc_status_enum_type (*special_function)();
  1226.  
  1227.     /* The textual name of the relocation type.
  1228.     */
  1229.   char *name;
  1230.  
  1231.     /* When performing a partial link, some formats must modify the
  1232.     relocations rather than the data - this flag signals this.
  1233.     */
  1234.   boolean partial_inplace;
  1235.  
  1236.     /* The src_mask is used to select what parts of the read in data are to
  1237.     be used in the relocation sum. Eg, if this was an 8 bit bit of data
  1238.     which we read and relocated, this would be 0x000000ff. When we have
  1239.     relocs which have an addend, such as sun4 extended relocs, the value
  1240.     in the offset part of a relocating field is garbage so we never use
  1241.     it. In this case the mask would be 0x00000000.
  1242.     */
  1243.   bfd_word src_mask;
  1244.  
  1245.     /* The dst_mask is what parts of the instruction are replaced into the
  1246.     instruction. In most cases src_mask == dst_mask, except in the above
  1247.     special case, where dst_mask would be 0x000000ff, and src_mask would
  1248.     be 0x00000000.
  1249.     */
  1250.   bfd_word dst_mask;           
  1251.  
  1252.     /* When some formats create PC relative instructions, they leave the
  1253.     value of the pc of the place being relocated in the offset slot of the
  1254.     instruction, so that a PC relative relocation can be made just by
  1255.     adding in an ordinary offset (eg sun3 a.out). Some formats leave the
  1256.     displacement part of an instruction empty (eg m88k bcs), this flag
  1257.     signals the fact.
  1258.     */
  1259.   boolean pcrel_offset;
  1260. } reloc_howto_type;
  1261.  
  1262. /* The HOWTO define is horrible and will go away.
  1263. */
  1264. #define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \
  1265.   {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}
  1266. typedef unsigned char bfd_byte;
  1267.  
  1268. typedef struct relent_chain {
  1269.   arelent relent;
  1270.   struct   relent_chain *next;
  1271. } arelent_chain;
  1272.  
  1273.  
  1274. /* If an output_bfd is supplied to this function the generated image
  1275. will be relocatable, the relocations are copied to the output file
  1276. after they have been changed to reflect the new state of the world.
  1277. There are two ways of reflecting the results of partial linkage in an
  1278. output file; by modifying the output data in place, and by modifying
  1279. the relocation record. Some native formats (eg basic a.out and basic
  1280. coff) have no way of specifying an addend in the relocation type, so
  1281. the addend has to go in the output data.  This is no big deal since in
  1282. these formats the output data slot will always be big enough for the
  1283. addend. Complex reloc types with addends were invented to solve just
  1284. this problem.
  1285. */
  1286. PROTO(bfd_reloc_status_enum_type,
  1287.                 bfd_perform_relocation,
  1288.                         (bfd * abfd,
  1289.                         arelent *reloc_entry,
  1290.                         PTR data,
  1291.                         asection *input_section,
  1292.                         bfd *output_bfd));
  1293. /* @node bfd_target
  1294. @subsection bfd_target
  1295. This structure contains everything that BFD knows about a target.
  1296. It includes things like its byte order, name, what routines to call
  1297. to do various operations, etc.   
  1298.  
  1299. Every BFD points to a target structure with its "xvec" member. 
  1300.  
  1301.  
  1302. Shortcut for declaring fields which are prototyped function pointers,
  1303. while avoiding anguish on compilers that don't support protos.
  1304. */
  1305. #define SDEF(ret, name, arglist) \
  1306.                 PROTO(ret,(*name),arglist)
  1307. #define SDEF_FMT(ret, name, arglist) \
  1308.                 PROTO(ret,(*name[bfd_type_end]),arglist)
  1309.  
  1310. /* These macros are used to dispatch to functions through the bfd_target
  1311. vector. They are used in a number of macros further down in bfd.h, and
  1312. are also used when calling various routines by hand inside the bfd
  1313. implementation.  The "arglist" argument must be parenthesized; it
  1314. contains all the arguments to the called function.
  1315. */
  1316. #define BFD_SEND(bfd, message, arglist) \
  1317.                ((*((bfd)->xvec->message)) arglist)
  1318.  
  1319. /* For operations which index on the bfd format 
  1320. */
  1321. #define BFD_SEND_FMT(bfd, message, arglist) \
  1322.             (((bfd)->xvec->message[(int)((bfd)->format)]) arglist)
  1323.  
  1324. /* This is the struct which defines the type of BFD this is.  The
  1325. "xvec" member of the struct bfd itself points here.  Each module
  1326. that implements access to a different target under BFD, defines
  1327. one of these.
  1328.  
  1329. FIXME, these names should be rationalised with the names of the
  1330. entry points which call them. Too bad we can't have one macro to
  1331. define them both! 
  1332.  
  1333. */
  1334. typedef struct bfd_target
  1335. {
  1336.  
  1337.     /* identifies the kind of target, eg SunOS4, Ultrix, etc 
  1338.     */
  1339.   char *name;
  1340.  
  1341.     /* The "flavour" of a back end is a general indication about the contents
  1342.     of a file.
  1343.     */
  1344.   enum target_flavour_enum {
  1345.     bfd_target_aout_flavour_enum,
  1346.     bfd_target_coff_flavour_enum,
  1347.     bfd_target_ieee_flavour_enum,
  1348.     bfd_target_oasys_flavour_enum,
  1349.     bfd_target_srec_flavour_enum} flavour;
  1350.  
  1351.     /* The order of bytes within the data area of a file.
  1352.     */
  1353.   boolean byteorder_big_p;
  1354.  
  1355.     /* The order of bytes within the header parts of a file.
  1356.     */
  1357.   boolean header_byteorder_big_p;
  1358.  
  1359.     /* This is a mask of all the flags which an executable may have set -
  1360.     from the set @code{NO_FLAGS}, @code{HAS_RELOC}, ...@code{D_PAGED}.
  1361.     */
  1362.   flagword object_flags;       
  1363.  
  1364.     /* This is a mask of all the flags which a section may have set - from
  1365.     the set @code{SEC_NO_FLAGS}, @code{SEC_ALLOC}, ...@code{SET_NEVER_LOAD}.
  1366.     */
  1367.   flagword section_flags;
  1368.  
  1369.     /* The pad character for filenames within an archive header.
  1370.     */
  1371.   char ar_pad_char;            
  1372.  
  1373.     /* The maximum number of characters in an archive header.
  1374.     */
  1375.  unsigned short ar_max_namelen;
  1376.  
  1377.     /* The minimum alignment restriction for any section.
  1378.     */
  1379.   unsigned int align_power_min;
  1380.  
  1381.     /* Entries for byte swapping for data. These are different to the other
  1382.     entry points, since they don't take bfd as first arg.  Certain other handlers
  1383.     could do the same.
  1384.     */
  1385.   SDEF (bfd_vma,      bfd_getx64, (bfd_byte *));
  1386.   SDEF (void,         bfd_putx64, (bfd_vma, bfd_byte *));
  1387.   SDEF (bfd_vma, bfd_getx32, (bfd_byte *));
  1388.   SDEF (void,         bfd_putx32, (bfd_vma, bfd_byte *));
  1389.   SDEF (bfd_vma, bfd_getx16, (bfd_byte *));
  1390.   SDEF (void,         bfd_putx16, (bfd_vma, bfd_byte *));
  1391.  
  1392.     /* Byte swapping for the headers
  1393.     */
  1394.   SDEF (bfd_vma,   bfd_h_getx64, (bfd_byte *));
  1395.   SDEF (void,          bfd_h_putx64, (bfd_vma, bfd_byte *));
  1396.   SDEF (bfd_vma,  bfd_h_getx32, (bfd_byte *));
  1397.   SDEF (void,          bfd_h_putx32, (bfd_vma, bfd_byte *));
  1398.   SDEF (bfd_vma,  bfd_h_getx16, (bfd_byte *));
  1399.   SDEF (void,          bfd_h_putx16, (bfd_vma, bfd_byte *));
  1400.  
  1401.     /* Format dependent routines, these turn into vectors of entry points
  1402.     within the target vector structure; one for each format to check.
  1403.     
  1404.     Check the format of a file being read.  Return bfd_target * or zero. 
  1405.     */
  1406.   SDEF_FMT (struct bfd_target *, _bfd_check_format, (bfd *));
  1407.  
  1408.     /* Set the format of a file being written.  
  1409.     */
  1410.   SDEF_FMT (boolean,            _bfd_set_format, (bfd *));
  1411.  
  1412.     /* Write cached information into a file being written, at bfd_close. 
  1413.     */
  1414.   SDEF_FMT (boolean,            _bfd_write_contents, (bfd *));
  1415.  
  1416.     /* The following functions are defined in @code{JUMP_TABLE}. The idea is
  1417.     that the back end writer of @code{foo} names all the routines
  1418.     @code{foo_}@var{entry_point}, @code{JUMP_TABLE} will built the entries
  1419.     in this structure in the right order.
  1420.     
  1421.     Core file entry points
  1422.     */
  1423.   SDEF (char *, _core_file_failing_command, (bfd *));
  1424.   SDEF (int,    _core_file_failing_signal, (bfd *));
  1425.   SDEF (boolean, _core_file_matches_executable_p, (bfd *, bfd *));
  1426.  
  1427.     /* Archive entry points
  1428.     */
  1429.  SDEF (boolean, _bfd_slurp_armap, (bfd *));
  1430.  SDEF (boolean, _bfd_slurp_extended_name_table, (bfd *));
  1431.  SDEF (void,   _bfd_truncate_arname, (bfd *, CONST char *, char *));
  1432.  SDEF (boolean, write_armap, (bfd *arch, 
  1433.                               unsigned int elength,
  1434.                               struct orl *map,
  1435.                               int orl_count, 
  1436.                               int stridx));
  1437.  
  1438.     /* Standard stuff.
  1439.     */
  1440.   SDEF (boolean, _close_and_cleanup, (bfd *));
  1441.   SDEF (boolean, _bfd_set_section_contents, (bfd *, sec_ptr, PTR,
  1442.                                             file_ptr, bfd_size_type));
  1443.   SDEF (boolean, _bfd_get_section_contents, (bfd *, sec_ptr, PTR, 
  1444.                                             file_ptr, bfd_size_type));
  1445.   SDEF (boolean, _new_section_hook, (bfd *, sec_ptr));
  1446.  
  1447.     /* Symbols and reloctions
  1448.     */
  1449.  SDEF (unsigned int, _get_symtab_upper_bound, (bfd *));
  1450.   SDEF (unsigned int, _bfd_canonicalize_symtab,
  1451.            (bfd *, struct symbol_cache_entry **));
  1452.   SDEF (unsigned int, _get_reloc_upper_bound, (bfd *, sec_ptr));
  1453.   SDEF (unsigned int, _bfd_canonicalize_reloc, (bfd *, sec_ptr, arelent **,
  1454.                                                struct symbol_cache_entry**));
  1455.   SDEF (struct symbol_cache_entry  *, _bfd_make_empty_symbol, (bfd *));
  1456.   SDEF (void,     _bfd_print_symbol, (bfd *, PTR, struct symbol_cache_entry  *,
  1457.                                       bfd_print_symbol_enum_type));
  1458. #define bfd_print_symbol(b,p,s,e) BFD_SEND(b, _bfd_print_symbol, (b,p,s,e))
  1459.   SDEF (alent *,   _get_lineno, (bfd *, struct symbol_cache_entry  *));
  1460.  
  1461.   SDEF (boolean,   _bfd_set_arch_mach, (bfd *, enum bfd_architecture,
  1462.                                        unsigned long));
  1463.  
  1464.   SDEF (bfd *,  openr_next_archived_file, (bfd *arch, bfd *prev));
  1465.   SDEF (boolean, _bfd_find_nearest_line,
  1466.         (bfd *abfd, struct sec  *section,
  1467.          struct symbol_cache_entry  **symbols,bfd_vma offset,
  1468.         CONST char **file, CONST char **func, unsigned int *line));
  1469.   SDEF (int,    _bfd_stat_arch_elt, (bfd *, struct stat *));
  1470.  
  1471.   SDEF (int,    _bfd_sizeof_headers, (bfd *, boolean));
  1472.  
  1473.   SDEF (void, _bfd_debug_info_start, (bfd *));
  1474.   SDEF (void, _bfd_debug_info_end, (bfd *));
  1475.   SDEF (void, _bfd_debug_info_accumulate, (bfd *, struct sec  *));
  1476.  
  1477.     /* Special entry points for gdb to swap in coff symbol table parts
  1478.     */
  1479.   SDEF(void, _bfd_coff_swap_aux_in,(
  1480.        bfd            *abfd ,
  1481.        PTR             ext,
  1482.        int             type,
  1483.        int             class ,
  1484.        PTR             in));
  1485.  
  1486.   SDEF(void, _bfd_coff_swap_sym_in,(
  1487.        bfd            *abfd ,
  1488.        PTR             ext,
  1489.        PTR             in));
  1490.  
  1491.   SDEF(void, _bfd_coff_swap_lineno_in,  (
  1492.        bfd            *abfd,
  1493.        PTR            ext,
  1494.        PTR             in));
  1495.  
  1496. } bfd_target;
  1497.  
  1498. /* Returns a pointer to the transfer vector for the object target
  1499. named target_name.  If target_name is NULL, chooses the one in the
  1500. environment variable GNUTARGET; if that is null or not defined then
  1501. the first entry in the target list is chosen.  Passing in the
  1502. string "default" or setting the environment variable to "default"
  1503. will cause the first entry in the target list to be returned,
  1504. and "target_defaulted" will be set in the bfd.  This causes
  1505. bfd_check_format to loop over all the targets to find the one
  1506. that matches the file being read.  
  1507. */
  1508. PROTO(bfd_target *, bfd_find_target,(CONST char *, bfd *));
  1509. /* This function returns a freshly malloced NULL-terminated vector of the
  1510. names of all the valid bfd targets. Do not modify the names 
  1511. */
  1512. PROTO(CONST char **,bfd_target_list,());
  1513. /* This routine is supplied a bfd and a format. It attempts to verify if
  1514. the file attatched to the bfd is indeed compatible with the format
  1515. specified (ie, one of @code{bfd_object}, @code{bfd_archive} or
  1516. @code{bfd_core}).
  1517.  
  1518. If the bfd has been set to a specific @var{target} before the call,
  1519. only the named target and format combination will be checked. If the
  1520. target has not been set, or has been set to @code{default} then all
  1521. the known target backends will be interrogated to determine a match.
  1522.  
  1523. The function returns @code{true} on success, otherwise @code{false}
  1524. with one of the following error codes: 
  1525. @table @code
  1526. @item 
  1527. invalid_operation
  1528. if @code{format} is not one of @code{bfd_object}, @code{bfd_archive}
  1529. or @code{bfd_core}.
  1530. @item system_call_error
  1531. if an error occured during a read -  even some file mismatches can
  1532. cause system_call_errros
  1533. @item file_not_recognised
  1534. none of the backends recognised the file format
  1535. @item file_ambiguously_recognized
  1536. more than one backend recognised the file format.
  1537. @end table
  1538. */
  1539. PROTO(boolean, bfd_check_format, (bfd *abfd, bfd_format format));
  1540. /* This function sets the file format of the supplied bfd to the format
  1541. requested. If the target set in the bfd does not support the format
  1542. requested, the format is illegal or the bfd is not open for writing
  1543. than an error occurs.
  1544. */
  1545. PROTO(boolean,bfd_set_format,(bfd *, bfd_format));
  1546. /* This function takes one argument, and enumerated type (bfd_format) and
  1547. returns a pointer to a const string "invalid", "object", "archive",
  1548. "core" or "unknown" depending upon the value of the enumeration.
  1549. */
  1550. PROTO(CONST char *, bfd_format_string, (bfd_format));
  1551. #endif
  1552.  
  1553.